TGML Signal Binding
<Bind> enables a dynamic (server/device controlled) update of an attribute of the immediate parent element.
The Name of the Bind element is exposed to the Graphics Editor bind tool as a binding point. For more information, see the TGML Common Attributes section.
The Bind element has a Description attribute that can be used to add a description of the binding. The Description can be exposed together with the Name and presented to the user in the bind tool.
Bind makes the parent element an "interactive" element. The TGML viewer is supposed to respond, for example, show a "change value" dialog box, when the user clicks the element.
Attribute | Type | Description |
---|---|---|
Attribute |
String |
The bound attribute of the parent element. |
Description |
String |
A user-defined description of the binding. |
Format |
Format |
Specifies the formatting of the subscribed data. See Remarks. |
PreventDefault |
Bool |
Cancels the default action normally taken by the implementation, for example, the viewer. See Remarks. |
DynamicUpdates |
DynamicUpdates |
Specifies if the Bind should be enabled or disabled. |
Remarks
Format is an instruction to the server of how the subscribed value is to be formatted.
"None" means "deliver the data as is". The data type is preserved (integer, float, boolean, string, etc.). You typically use conversion elements to convert the server variable value to a TGML element attribute value.
"Presentation" is an instruction to the server: Deliver the text representation of the variable value, if any (for example, On/Off instead of 0/1). "Presentation" is typically used when the data is to be presented by a Text element without any value conversions.
The “default action” when a user clicks an element containing a Bind element, is usually to open an “edit value” dialog. This action is canceled when PreventDefault is set to 'True'.
PreventDefault is typically set to 'True' in components that mimic interactive controls such as check boxes and spin buttons. In such components, the value is set in a JavaScript using the setValue function.
DynamicUpdates can be used to, by scripting, turn off a group of Binds initially to load a picture faster. Subscriptions can in some systems be performance heavy, so perhaps only a select few Binds need to be active in a picture. By default this attribute is set to “Enabled”.
Example of dynamic text without any conversion elements using the presentation format:
<TGML>
<Text ...>
<Bind Name="Status" Attribute="TextContent" Format="Presentation" />
This string is displayed as default.
</Text>
</TGML>
Example showing a Bind that will be enabled/disabled on the OnMouseOver event:
<TGML>
<Component Clip="False" ContentHeight="113.0" ContentWidth="166.0" Height="113.0" Left="73.0" Top="253.0" Width="166.0">
<Text Left="65.0" Top="48.0">
<Expose ExposedAttribute="Content" Name="EditModeText"/>
<Bind Attribute="Content" Format="Presentation" Name="val">
<Expose ExposedAttribute="Name"/>
</Bind><! [CDATA[Text] ]>
</Text>
<Script OnMouseOver="over"><! [CDATA [
function over(evt){
var component = evt.getCurrentTarget();
var bindings = component.getElementsByTagKame("Bind");
var bind = null;
for(var i = 0; i < bindings.getLength(); i++){
bind = bindings.item(i);
if (bind.getAttribute("DynamicUpdates") == "Disable"){
bind.setAttribute("DynamicUpdates", "Enable");
}
else{
bind.setAttribute("DynamicUpdates", "Disable");
}
}
}
]]></Script>
</Component>
</TGML>